package com.book.chapter.common.utils;

import com.book.book.NovelSiteEnum;
import com.book.chapter.service.BXWX9ChapterSpider;
import com.book.chapter.service.ChapterSpider;
import com.book.chapter.service.DefaultChapterSpider;

/***
 * @Author Lin
 * @Date Create By 14:51 2017/10/6
 * @Description
 */
public final class ChapterSpiderFactory {
    // 不允许实例化
    private ChapterSpiderFactory() {
    }

    /***
     * 通过给定的url，返回一个实现了ChapterSpider接口的实现类
     * @param url
     * @return
     */
    public static ChapterSpider getChapterSpider(String url) {
        NovelSiteEnum novelSiteEnum = NovelSiteEnum.getEnumByUrl(url);
        ChapterSpider chapterSpider = null;
        switch (novelSiteEnum) {
            case BiXiaWenXue9:
                chapterSpider = new BXWX9ChapterSpider();
                break;
            case BiQuGe:
            case BiXiaWenXue:
            case ShenShuWang:
            case DingDianXiaoShuo:
            case KanShuZhong:
                chapterSpider = new DefaultChapterSpider();
                break;
        }
        return chapterSpider;
    }
}

